require "makeupType.lua"
require "makeUpStrength.lua"
require "beautyStrength.lua"
require "config.lua"

function initialize(scene)
  makeup = KuruMakeupNode.create(true)
  scene:addNodeAndRelease(makeup)

  EngineStatus.instance():setBoolean("useBuiltInDistortionInScript", true)

  local distortionNode = KaleFaceDistortionNode.create()
  distortionNode:loadDistortionFromString(SceneConfig.instance().distortionJson)
  scene:addNode(distortionNode)
  distortionNode:release()

  makeup:setPathAndBlendModeById(KuruMakeupNodeType.BLUSH, blushNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.CONTOUR, contourNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.LIP_COLOR, lipColorNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYE_COLOR, eyeColorNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYEBROWS, eyeBrowsNum, eyeBrowsBlendMode)

  --eyeShadow
  if eyeShadowLayer0Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER0, eyeShadowLayer0Num, eyeShadowLayer0BlendMode)
  end
  if eyeShadowLayer1Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER1, eyeShadowLayer1Num, eyeShadowLayer1BlendMode)
  end
  if eyeShadowLayer2Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER2, eyeShadowLayer2Num, eyeShadowLayer2BlendMode)
  end

  --eyeLiner
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYELINER, eyeLinerNum, eyeLinerBlendMode)

  --eyeLashes
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYELASHES, eyeLashesNum, eyeLashesBlendMode)

  makeup_param = makeup:getParam()
  -- beauty
  makeup_param.laughLine = laughLine
  makeup_param.eyeLut = eyeLut
  makeup_param.eyePlim = eyePlim
  makeup_param.darkCircle = darkCircle
  makeup_param.whiteTeeth = whiteTeeth

  -- makeup
  makeup_param.faceContour = faceContour
  makeup_param.cheek = cheek
  makeup_param.lip = lip
  makeup_param.colorLens = colorLens
  makeup_param.eyeBrow = eyeBrow
  makeup_param.eyeShadow = eyeShadow
  makeup_param.eyeLiner = eyeLiner
  makeup_param.eyeLashes = eyeLashes
end

function frameReady(scene, elapsedTime)

  -- ================서버에 등록 할 때 삭제===================
  setParameters()
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.BLUSH, blushNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.CONTOUR, contourNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.LIP_COLOR, lipColorNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYE_COLOR, eyeColorNum, BlendMode.None)
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYEBROWS, eyeBrowsNum, eyeBrowsBlendMode)
  --eyeShadow
  if eyeShadowLayer0Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER0, eyeShadowLayer0Num, eyeShadowLayer0BlendMode)
  end
  if eyeShadowLayer1Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER1, eyeShadowLayer1Num, eyeShadowLayer1BlendMode)
  end
  if eyeShadowLayer2Num > 0 then
    makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYESHADOW_LAYER2, eyeShadowLayer2Num, eyeShadowLayer2BlendMode)
  end

  --eyeLiner
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYELINER, eyeLinerNum, eyeLinerBlendMode)

  --eyeLashes
  makeup:setPathAndBlendModeById(KuruMakeupNodeType.EYELASHES, eyeLashesNum, eyeLashesBlendMode)
end
